﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FJERP.BLL;
using FJERP.Model;
using System.Data;

namespace FJERP
{
    public partial class SupplierEdit : System.Web.UI.Page
    {
        SupplierBLL bll = new SupplierBLL();

        protected void UpdateLoad()
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            DataTable table = bll.SuppLier_Hu(id);
            this.Supplier_Name.Value = table.Rows[0][1].ToString();
            this.Supplier_People.Value = table.Rows[0][2].ToString();
            this.Supplier_Phone.Value = table.Rows[0][3].ToString();
            this.Supplier_Addr.Value = table.Rows[0][4].ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                if(Request.QueryString["id"].ToString()!=null)
                {
                    UpdateLoad();
                }
            }
        }

        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            Supplier s = new Supplier();
            s.Supplier_Id = Convert.ToInt32(Request.QueryString["id"]);
            s.Supplier_Name = this.Supplier_Name.Value;
            s.Supplier_People = this.Supplier_People.Value;
            s.Supplier_Phone = this.Supplier_Phone.Value;
            s.Supplier_Addr = this.Supplier_Addr.Value;
            if(bll.UptSupplier(s)>0)
            {
                Response.Write("<script>alert('修改成功!!!');location.href='SupplierShow.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败!!!')</script>");
            }
        }
    }
}